@extends('admin.main')
@section('body')
    <div class="main-title">
        <h2>水桶品牌管理</h2>
    </div>

    <!-- 表格列表 -->
    <div class="tb-unit posr">
        <div class="cf">
            <div class="fl">
                <a class="btn" href="{{urlAdmin('bucketCategory','getAdd')}}">新 增</a>
            </div>

            <!-- 高级搜索 -->
            <div class="search-form fr cf">
                <div class="sleft">
                    <div class="drop-down" style="width: 200px;">
                        <span id="sch-sort-txt" class="sort-txt" style="width: 170px;" data="{{request('shop_id')}}">全部</span>
                        <i class="arrow arrow-down"></i>
                        <ul id="sub-sch-menu" class="nav-list hidden">
                            <li><a href="javascript:;" style="width: 170px;" value="">全部</a></li>
                            @if(count($shopList))
                                @foreach($shopList as $v)
                                    <li><a href="javascript:;" style="width: 170px;" value="{{$v['id']}}">{{$v['shop_name']}}</a></li>
                                @endforeach
                            @endif
                        </ul>
                    </div>
                </div>
                {{--<div class="btn-group-click adv-sch-pannel fl">--}}
                {{--<button class="btn">高 级<i class="btn-arrowdown"></i></button>--}}
                {{--<div class="dropdown cf">--}}
                {{--<div class="row">--}}
                {{--<label>更新时间：</label>--}}
                {{--<input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始时间" /> ---}}
                {{--<input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="结束时间" />--}}
                {{--</div>--}}
                {{--<div class="row">--}}
                {{--<label>创建者：</label>--}}
                {{--<input type="text" name="nickname" class="text input-2x" value="" placeholder="请输入用户名">--}}
                {{--</div>--}}
                {{--</div>--}}
                {{--</div>--}}
            </div>
        </div>
        <div class="category">
            <div class="hd cf">
                <div class="fold">折叠</div>
                <div class="order">排序</div>
                {{--<div class="order">发布</div>--}}
                <div class="name">名称</div>
            </div>
            @if(count($tree))
                @foreach($tree as $v)
                    <dl class="cate-item">
                        <dt class="cf">
                        <form action="{{urlAdmin('bucketCategory','postEdit')}}" method="post">
                            {{--<div class="btn-toolbar opt-btn cf">--}}
                                {{--<a title="编辑"--}}
                                   {{--href="{{urlAdmin('bucketCategory','getEdit',['id'=>$v['id']])}}">编辑</a>--}}
                                {{--<a title="{{show_status_op($v['status'])}}"--}}
                                   {{--href="{{urlAdmin('bucketCategory','anySetStatus',['ids'=>$v['id'],'status'=>abs(1-$v['status'])])}}"--}}
                                   {{--class="ajax-get">{{show_status_op($v['status'])}}</a>--}}
                            {{--</div>--}}
                            <div class="fold"><i></i></div>
                            <div class="order">
                                <input type="text" name="sort" class="text input-mini" value="{{$v['sort']}}">
                            </div>
                            {{--<div class="order">{{$v['allow_publish']?'是':'否'}}</div>--}}
                            <div class="name">
                                <span class="tab-sign"></span>
                                <input type="hidden" name="id" value="{{$v['id']}}">
                                <input type="text" name="title" readonly class="text" value="{{$v['title']}}">
                                <span class="help-inline msg"></span>
                            </div>
                        </form>
                        </dt>
                    </dl>
                @endforeach
            @else
                <div align="center">
                    <span style="text-align: center;font-size:15px;">aOh! 暂时还没有内容!</span>
                </div>
            @endif
        </div>
    </div>
    <!-- /表格列表 -->
@endsection
@section('script')
    <script type="text/javascript">
        (function ($) {
            /* 分类展开收起 */
            $(".category dd").prev().find(".fold i").addClass("icon-unfold")
                    .click(function () {
                        var self = $(this);
                        if (self.hasClass("icon-unfold")) {
                            self.closest("dt").next().slideUp("fast", function () {
                                self.removeClass("icon-unfold").addClass("icon-fold");
                            });
                        } else {
                            self.closest("dt").next().slideDown("fast", function () {
                                self.removeClass("icon-fold").addClass("icon-unfold");
                            });
                        }
                    });

            /* 三级分类删除新增按钮 */
            $(".category dd dd .add-sub").remove();

            /* 实时更新分类信息 */
            $(".category")
                    .on("submit", "form", function () {
                        var self = $(this);
                        $.post(
                                self.attr("action"),
                                self.serialize(),
                                function (data) {
                                    /* 提示信息 */
                                    var name = data.status ? "success" : "error", msg;
                                    msg = self.find(".msg").addClass(name).text(data.info)
                                            .css("display", "inline-block");
                                    setTimeout(function () {
                                        msg.fadeOut(function () {
                                            msg.text("").removeClass(name);
                                        });
                                    }, 1000);
                                },
                                "json"
                        );
                        return false;
                    })
                    .on("focus", "input", function () {
                        $(this).data('param', $(this).closest("form").serialize());

                    })
                    .on("blur", "input", function () {
                        if ($(this).data('param') != $(this).closest("form").serialize()) {
                            $(this).closest("form").submit();
                        }
                    });
        })(jQuery);

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
                var shop_id = $(this).attr("value");
                window.location.href = '{{urlAdmin('bucketCategory','getShopIndex')}}?shop_id='+shop_id;
            })
        });
    </script>
@endsection
